/***
 * @title: sys_log ServiceImpl file
 * @author: seasonszx dev
 * @datetime: 2018-01-24 14:08:07
 * @version: 1.0.0
 */
package com.zx.platform.zanadu.manager.serviceimpl;


import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.PageHelper;
import com.zx.platform.zanadu.manager.mapper.SysLogMapper;
import com.zx.platform.zanadu.manager.mongo.bean.SysLogRepository;
import com.zx.platform.zanadu.manager.pojo.SysLog;
import com.zx.platform.zanadu.manager.service.SysLogService;

@Service
@Transactional
public class SysLogServiceImpl implements SysLogService {

	@Autowired
    private SysLogMapper sysLogMapper;
	
	@Autowired
	SysLogRepository sysLogRepository;
	
	// 基本信息新增服务
	@Override
	public int insert(SysLog info) {
		String str = JSON.toJSONString(info,
				SerializerFeature.WriteMapNullValue,
				SerializerFeature.WriteNullStringAsEmpty);
		System.out.println(str);
		
		SysLog info2 = JSON.parseObject(str, SysLog.class);
		
		sysLogRepository.save(info2);
		return sysLogMapper.insert(info);
	}
	
	// 基本信息修改服务
	@Override
	public int update(SysLog info) {
		return sysLogMapper.update(info);
	}

	// 主键删除服务
	@Override
	public int deleteByPrimaryKey(String primarykey) {
		return sysLogMapper.deleteByPrimaryKey(primarykey);
	}

	// 主键查询对象服务
	@Override
	public SysLog selectByPrimaryKey(String primarykey) {
		return sysLogMapper.selectByPrimaryKey(primarykey);
	}

	// 全查集合服务
	@Override
	public List<SysLog> selectAll() {
		return sysLogMapper.selectAll();
	}

	// 条件查询集合
	@Override
	public List<SysLog> selectByCondition(Map<String, Object> map) {
		return sysLogMapper.selectByCondition(map);
	}
	
	// 分页条件查询集合
	@Override
	public List<SysLog> selectByPageCondition(Map<String, Object> map) {
		int pageNo = Integer.parseInt(map.get("pageNo").toString());
		int pageSize = Integer.parseInt(map.get("pageSize").toString());
		PageHelper.startPage(pageNo,pageSize);
		return sysLogMapper.selectByPageCondition(map);
	}

}
